package com.meixiang.fragment.collect;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meixiang.R;
import com.meixiang.adapter.CollectAdapter;
import com.meixiang.entity.collect.CollectDateEntity;
import com.meixiang.entity.collect.CollectEntity;
import com.meixiang.main.BaseFragment;
import com.meixiang.view.swipetoloadlayout.base.SwipeToLoadLayout;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 服务
 * xiejingwen
 */
public class ServiceCollectFragment extends BaseFragment {


    @Bind(R.id.swipe_target)
    RecyclerView mSwipeTarget;
    @Bind(R.id.refresh)
    SwipeToLoadLayout mRefresh;
    CollectAdapter mAdapter;
    private String favType = "2" ;
    private CollectEntity mCollectEntity ;
    private List<CollectDateEntity> mCollectList ;
    private List<CollectDateEntity> serviceList ;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_service_collect, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void setData() {
       /* HttpParams params = new HttpParams();
        params.put("favType",favType);
        params.put("pageSize","10");
        params.put("pageNo","1");
        HttpUtils.post(Config.COLLECT_LIST, params, new HttpCallBack(getActivity()) {
            @Override
            public void onSucceed(JSONObject result, String code, String message) {
                mCollectEntity = new Gson().fromJson(result.toString(),CollectEntity.class);
                mCollectList = mCollectEntity.getmCollectDateList();
                serviceList = new ArrayList<>() ;
                for(int i=0;i<mCollectList.size();i++){
                    if(favType.equals(mCollectList.get(i).getFavType())){ //去掉不是商品的收藏数据
                        serviceList.add(mCollectList.get(i)) ;
                    }
                }
                if (serviceList.size()==0){
                    showNoData("暂无收藏");
                }else{
                    mAdapter.addData(serviceList);
                }
            }

            @Override
            public void onError(String code, String message) {

            }
        });

        mSwipeTarget.setLayoutManager(new LinearLayoutManager(activity,LinearLayoutManager.VERTICAL,false));
        mAdapter=new CollectAdapter(getContext(),activity);
        mSwipeTarget.setAdapter(mAdapter);*/
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
